package es.acm.calendario
{
	import flash.display.BitmapData;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	import spark.components.Button;
	import spark.components.HGroup;
	import spark.components.Image;
	import spark.components.Label;
	import spark.components.SkinnableContainer;

	[Event(name="next", type="flash.events.Event")]
	[Event(name="previous", type="flash.events.Event")]
	
	public class HeaderCalendar extends HGroup
	{
		[Embed(source="assets/previous.png")]
		private var PreviousIcon:Class;
		[Embed(source="assets/next.png")]
		private var NextIcon:Class;
		[Bindable]
		public var title:Label;
		
		public function HeaderCalendar()
		{
			super();
			gap=0;
			paddingBottom = 2;
			paddingLeft = 0;
			paddingRight = 0;
			verticalAlign = 'middle';
			horizontalAlign = 'center';
			//height = 20;
		}
		
		override protected function createChildren():void {
			super.createChildren();
			
			var btLeft:Image = new Image();
			btLeft.source = new PreviousIcon();
			btLeft.addEventListener(MouseEvent.CLICK, previousMonth);
			//btLeft.setStyle('icon', PreviousIcon);
			//btLeft.height = 30;
			
			title = new Label();
			title.percentWidth = 100;
			/*title.setStyle('textAlign', 'center');
			title.setStyle('fontSize', '24');
			title.setStyle('fontWeigh', 'bold');*/
			
			var btRight:Image = new Image();
			btRight.source = new NextIcon();
			btRight.addEventListener(MouseEvent.CLICK, nextMonth);
			//btRight.setStyle('icon', NextIcon);
			//btRight.height = 30;
			
			addElement(btLeft);
			addElement(title);
			addElement(btRight);
		}
		
		private function nextMonth(event:MouseEvent):void {
			dispatchEvent(new Event('next', true));
		}
		
		private function previousMonth(event:MouseEvent):void {
			dispatchEvent(new Event('previous', true));
		}
	}
}